package account.model;

import java.io.Serializable;
import java.util.Date;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;

import account.command.CommandException;
import account.command.SaveAccountComman;

@ManagedBean( name="accountModel")
@RequestScoped
public class AccountModel implements Serializable{
	
	private Integer id_account = -1;
	private String name = "";
	private Integer value = 0;
	private Integer period = 0;
	private String number = "";
	private Integer percent = 0;
	private Date start_date = new Date();
	private Integer cost = 0;
	
	public AccountModel() {}
	
	public AccountModel(Integer id_account, String name, Integer value, Integer period) {
		this.id_account = id_account;
		this.name = name;
		this.value = value;
	}
	
	public AccountModel( String name, Integer value, Integer period) {
		this( -1, name, value, period );
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public Integer getValue() {
		return value;
	}
	public void setValue(Integer value) {
		this.value = value;
	}

	public Integer getCost() {
		return cost;
	}

	public void setCost(Integer cost) {
		this.cost = cost;
	}

	public Integer getId_account() {
		return id_account;
	}

	public void setId_account(Integer id_account) {
		this.id_account = id_account;
	}

	public Integer getPeriod() {
		return period;
	}

	public void setPeriod(Integer period) {
		this.period = period;
	}

	
	public String getNumber() {
		return number;
	}

	public void setNumber(String number) {
		this.number = number;
	}

	public Integer getPercent() {
		return percent;
	}

	public void setPercent(Integer percent) {
		this.percent = percent;
	}

	public Date getStart_date() {
		return start_date;
	}

	public void setStart_date(Date start_date) {
		this.start_date = start_date;
	}

	public void save() {
		SaveAccountComman command = new SaveAccountComman();
		command.inModel = this;
		try {
			command.execute();
		} catch (CommandException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
}
